// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** uploadFile POST /api/file/upload */
export async function uploadFileUsingPOST(
    body: { id: any; file: any },
    options?: { [p: string]: any },
) {
    const formData = new FormData();

    Object.keys(body).forEach((ele) => {
        const item = (body as any)[ele];

        if (item !== undefined && item !== null) {
            formData.append(
                ele,
                typeof item === 'object' && !(item instanceof File) ? JSON.stringify(item) : item,
            );
        }
    });

    return request<API.BaseResponseMapStringObject_>('/api/file/upload', {
        method: 'POST',
        data: formData,
        requestType: 'form',
        ...(options || {}),
    });
}

/** uploadFiles POST /api/file/uploads */
export async function uploadFilesUsingPOST(body: string[], options?: { [key: string]: any }) {
    return request<API.BaseResponseMapStringObject_>('/api/file/uploads', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        data: body,
        ...(options || {}),
    });
}
